package io_exercise;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos2=new FileOutputStream("pw2.txt");
        OutputStreamWriter osw2=new OutputStreamWriter(fos2, StandardCharsets.UTF_8);
        BufferedWriter bw2=new BufferedWriter(osw2);
        PrintWriter pw2=new PrintWriter(bw2,true);
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入内容，单独输入exit时退出");
        while (true){
            String line2=scan.nextLine();
            if("exit".equals(line2)){
                System.out.println("写出完毕，退出");
                break;
            }
            pw2.println(line2);
        }
        pw2.close();
    }
}
